home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.3 / Video Toaster v4.3.iso / 3.1 / toasterall / arexx_examples / tpaint / tpaintstrybd.rexx < prev    next >
OS/2 REXX Batch file  |  1992-01-29  |  9KB  |  257 lines

  1. /* TPaintStryBd.rexx -- A ToasterPaint Frame StoryBoarder  */
  2. /* By Arnie Cachelin © 1992 NewTek Inc */
  3.  
  4. /*
  5. This program will take a series of numbered frames (like from LightWave), shrink
  6. them, save the shrunken images to the 'TempPath' specified or RAM:, then place
  7. them on a single frame in 3x3, 4x4, or 5x5 format.  It adds a nice little embossed
  8. border for each frame. The final storyboard pictures are saved with the original
  9. frames.  If more than one page of frames is specified, more than one storyboard
  10. image will be created.
  11.   To use it, type 'rx TPaintStryBd' followed by the directory where the frames will
  12. be found, the base name of the frames (without the 001 part).  Optional parameters are
  13. a TempPath, where shrunken frames will be stored (Default=RAM:), the frame size,
  14. either S, M, or L for 3x3 to 5x5 storyboards (Default=M), the number of frames, frame
  15. number to start on, and the frame step (Default=1, draw every frame).
  16.   This program contains a large set of useful ARexx-ToasterPaint functions which can
  17. be used in your own programs.
  18.  */
  19.  
  20. ARG inpath BaseName temppath FrameSize LastFrame Frame FramesToSkip
  21. if inpath="" | basename="" then do
  22.     say "USAGE: rx StoryBoard inpath basename [TempPath [FrameSize(S|M|L) [LastFrame [FirstFrame [Step]]]]]"
  23.     exit
  24. end
  25. if TempPath="" then TempPath="RAM:"
  26. if frame="" then frame=0
  27. firstframe=frame
  28. if lastframe="" then lastframe=-1
  29. if framesize="" then framesize="M"
  30. if framestoskip="" then framestoskip=1
  31.  
  32. fwide.L=250
  33. fhigh.L=160
  34. fwide.M=188
  35. fhigh.M=120
  36. fwide.S=148
  37. fhigh.S=92
  38. FramesPerSide.L=3        /* as in 3x3, 4x4, 5x5, etc. we could even add T for tiny -- 6x6 */
  39. FramesPerSide.M=4
  40. FramesPerSide.S=5
  41. PageWide=752
  42. PageHigh=480
  43. Label=0
  44.  
  45. interpret "fwide=fwide."FrameSize  /* Value of framesize selects value of fwide */
  46. interpret "fhigh=fhigh."FrameSize
  47. interpret "FramesPerSide=FramesPerSide."FrameSize
  48.  
  49. FramesPerPage=FramesPerSide*FramesPerSide
  50. LastFrameNum=LastFrame * FramesToSkip + FirstFrame
  51. say "FramesToSkip="FramesToSkip
  52. say "LastFrameNum="lastframenum
  53.  
  54. if pos('DigiPaint',show(ports))=0 then do
  55.   say "Can't find ToasterPaint!"
  56.   exit
  57.   end
  58.  
  59. Address "DigiPaint"     /* Tell ARexx where commands go  */
  60.  
  61. 'Cbx0'        /* Choose color 0 (black) */
  62. 'Clrs'        /* Clear the screen */
  63. 'Maxe'        /* Set edge blend level to max */
  64. 'Maxc'        /* Set center blend level to max  */
  65. Pic = getname(temppath,BaseName,Frame)
  66. if ~Exists(temppath||Pic) Then
  67.   t=ShrinkFrames(inpath,temppath,BaseName,FirstFrame,LastFrame,FrameSize,BW,FramesToSkip)
  68. 'Clrs'        /* Clear the screen */
  69. PageHas = 0
  70. Page=1
  71. Do While Exists(temppath||Pic)
  72.   LeftEdge = (((PageHas)//(FramesPerSide))*fwide) /* (Frame across // frames wide)*wide */
  73.   TopEdge = (((PageHas)%(FramesPerSide))*fhigh)  /* frame mod frames high     */
  74.   t=LoadBrush(temppath,Pic)
  75.   'Pend' LeftEdge+fwide%2 TopEdge+fhigh%2
  76.   'Penu' LeftEdge+fwide%2 TopEdge+fhigh%2
  77.   SAY pic LeftEdge+fwide%2 TopEdge+fhigh%2
  78.   PageSaved=0
  79. /*     ADDRESS Command "Delete "temppath||pic */
  80.   IF bord>0 then t=EmbossBorder(leftedge,topedge,fwide-1,fhigh-1,4)
  81.   'Pmcl'        /* Normal draw Mode */
  82.     PageHas = PageHas +1
  83.   if lastframe~=-1 then
  84.     if (frame>=LastFrameNum) then break
  85.     If PageHas = FramesPerPage then Do
  86.     t=SaveRGB(inpath,basename||".strybd"||FrameSize||Page)
  87.     PageSaved=1
  88.       Page=Page+1
  89.         PageHas = 0
  90.     'Clrs'        /* Clear the screen */
  91.         End
  92.   Frame = Frame + FramesToSkip
  93.   Pic = getname(temppath,BaseName,Frame)
  94. end
  95. If PageSaved = 0 then t=SaveRGB(inpath,basename||".strybd"||FrameSize||Page)
  96. 'Shco'        /* Render canvas to composite output */
  97. exit
  98.  
  99. CutBrush: PROCEDURE  /* Cut out a brush with corners at (x1,y1) and (x2,y2) */
  100.   arg x1, y1, x2, y2
  101.   'Dotb'        /* smallest brush size */
  102.   'Drre'        /* Rectangle mode  */
  103.   'Scis'        /* Scissors on, for cutting a brush  */
  104.   'Pend' x1 y1  /* Get in top Left corner  */
  105.   'Penu' x2 y2  /* lift pen to get brush!  */
  106.   return 0
  107.  
  108. MapBrush: PROCEDURE  /* Size swap brush into rectangle with corners at (x1,y1) and (x2,y2) */
  109.   arg x1, y1, x2, y2 /* if there is no swap brush, whole screen is used! */
  110.   'Flon'        /* Fill On */
  111.   'Maxc'        /* Set center transparency off */
  112.   'Maxe'        /* Set edge transparency off */
  113.   'Aaon'        /* Anti-alias on */
  114.   'Txma'        /* Texture mapping on, fill on, draw rectangles  */
  115.   'Drre'        /* Draw Rectangles */
  116.   'Pend' x1 y1  /* Get in top Left corner  */
  117.   'Penu' x2 y2  /* lift pen  */
  118.   'Flof'        /* fill off  */
  119.   'Pmcl'        /* Normal draw Mode */
  120.   return 0
  121.  
  122. MapScreen: PROCEDURE  /* Size full screen into rectangle with corners at (x1,y1) and (x2,y2) */
  123.   arg x1, y1, x2, y2     /* rectangle is drawn on swap screen */
  124.   'Pmcl'        /* Normal draw Mode */
  125.   'Maxc'        /* Set center transparency off */
  126.   'Maxe'        /* Set edge transparency off */
  127.   'Flon'        /* Fill On */
  128.     'Bdel'                /* Delete swap brush */
  129.     'Dotb'                /* Delete any current cut-out brush */
  130.   'Drre'        /* Draw Rectangles */
  131.   'Swap'        /* Jump to (blank) swap screen! */
  132.   'Pend' x1 y1  /* Get in top Left corner  */
  133.   'Penu' x2 y2  /* Lift pen at bottom right */
  134.     'Undo'                /* Un-draw solid rectangle */
  135.     'Rubi'                /* Internal Rub-Thru on... use picture in swap screen as source */
  136.   'Txma'        /* Texture mapping on, since there is no brush, it will use whole screen */
  137.     'Redo'                /* Re-draw rectangle, this time with texture map of swap screen */
  138.   'Flof'        /* Fill off  */
  139.   'Pmcl'        /* Normal draw Mode */
  140.   return 0
  141.  
  142. LoadRGB: PROCEDURE   /* Load Picture */
  143.   arg dirname, filename
  144.   'Lo24'                 /* Call file requester  */
  145.   'Dnam'dirname          /* Enter file path  */
  146.   'Dsel'                 /* Hit return on directory */
  147.   'Fnam'filename         /* Enter File name  */
  148.   'Okls'                 /* Hit the OK button  */
  149.   return 0
  150.  
  151. SaveRGB: PROCEDURE   /* Save Picture */
  152.   arg dirname, filename
  153.   'Sa24'                 /* Call file requester  */
  154.   'Dnam'dirname          /* Enter file path  */
  155.   'Dsel'                 /* Hit return on directory */
  156.   'Fnam'filename         /* Enter File name  */
  157.   'Okls'                 /* Hit the OK button  */
  158.   return 0
  159.  
  160. LoadBrush: PROCEDURE   /* Load Brush */
  161.   arg dirname, filename
  162.   'Lobr'                 /* Call file requester  */
  163.   'Dnam'dirname          /* Enter file path  */
  164.   'Dsel'                 /* Hit return on directory */
  165.   'Fnam'filename         /* Enter File name  */
  166.   'Okls'                 /* Hit the OK button  */
  167.   return 0
  168.  
  169. SaveBrush: PROCEDURE   /* Save Brush */
  170.   arg dirname, filename
  171.   'Sabr'                 /* Call file requester  */
  172.   'Dnam'dirname          /* Enter file path  */
  173.   'Dsel'                 /* Hit return on directory */
  174.   'Fnam'filename         /* Enter File name  */
  175.   'Okls'                 /* Hit the OK button  */
  176.   return 0
  177.  
  178. LoadFrameStore: PROCEDURE   /* Load FrameStore */
  179.   arg filename           /* must have ###.fs on front! */
  180.   'Loco'                 /* Call file requester  */
  181.   'Fnam'filename         /* Enter File name  */
  182.   'Okls'                 /* Hit the OK button  */
  183.   return 0
  184.  
  185. SaveFrameStore: PROCEDURE   /* Save FrameStore */
  186.   arg filename           /* must have ###.fs on front! */
  187.   'Saco'                 /* Call file requester  */
  188.   'Fnam'filename         /* Enter File name  */
  189.   'Okls'                 /* Hit the OK button  */
  190.   return 0
  191.  
  192. ShrinkFrames: PROCEDURE  EXPOSE Host fwide. fhigh.
  193.   arg inpath, outpath, BaseName, Frame, LastFrame, FrameSize, BW, FramesToSkip
  194.   LastFrameNum=LastFrame * FramesToSkip
  195.   Pic = getname(inpath,BaseName,Frame)
  196.     say pic
  197.   Do While Exists(inpath||Pic)
  198.     t=LoadRGB(inpath,pic)
  199.     say pic
  200.     say FrameSize fwide.FrameSize fhigh.FrameSize
  201.     'Swap'                  /* jump to swap screen! */
  202.     'Cbx0'                                    /* Pick color zero to clear  */
  203.     'Clrs'                                    /* Clear screen  */
  204.     'Swap'                                    /* jump to picture screen! */
  205.     t=MapScreen(0,0,fwide.FrameSize, fhigh.FrameSize)
  206.     t=CutBrush(0,0,fwide.FrameSize, fhigh.FrameSize)
  207.     t=SaveBrush(outpath,pic)
  208.     if lastframe~=-1 then
  209.       if (frame>=LastFrameNum) then return 0
  210.     Frame = Frame+FramesToSkip
  211.     Pic = getname(inpath,BaseName,Frame)
  212.     End
  213.   return 1
  214.  
  215. Rectangle: PROCEDURE
  216.   arg x,y,w,h
  217.   'Drre'
  218.   'Dotb'
  219.   'Pend' x y
  220.   'Penu' x+w y+h
  221.   return 0
  222.  
  223. Line: PROCEDURE
  224.   arg x,y,x2,y2
  225.     'Bsmo'                    /* Connect the dots drawing */
  226.   'Pend' x y
  227.   'Penu' x2 y2
  228.   return 0
  229.  
  230. EmbossBorder: PROCEDURE
  231.   arg x, y, Width, Height, Thick
  232.   'Pmcl'          /* Normal paint mode */
  233.   'Dotb'          /* One pixel brush */
  234.   'Bsmo'          /* Smooth Draw Mode */
  235.   do i=0 to thick
  236.     x1=x+i
  237.     y1=y+i
  238.     x2=x+Width-i
  239.     y2=y+Height-i
  240.     'Pmln'         /* Lighten Mode */
  241.     'Pend' x2 y1   /* top */
  242.     'Move' x1 y1
  243.     'Move' x1 y2
  244.     'Penu' x1 y2   /* Left  */
  245.     'Pmdn'         /* Darken Mode */
  246.     'Pend' x2 y1   /*  Right */
  247.     'Move' x2 y2
  248.     'Move' x1 y2
  249.     'Penu' x1 y2    /* Bottom  */
  250.   end i
  251.   'Pmcl'          /* Normal paint mode */
  252.   return 1
  253.  
  254. GetName: PROCEDURE  /* stripped down version for Toaster frames with ALWAYS 3 digits */
  255.     arg path, name, number
  256.     return (strip(name)||right(strip(number),3,"0"))
  257.